package creationPattern.Singleton;

import java.lang.reflect.Constructor;

/**
 * 反射对单例的破坏
 */
public class Test_Reflect {
    public static void main(String[] args) {
        Class<Singleton_05> clazz = Singleton_05.class;
        try {
            // 获取私有构造方法
            Constructor<Singleton_05> constructor = clazz.getDeclaredConstructor();
            constructor.setAccessible(true);
            Singleton_05 singleton05 = constructor.newInstance();

            System.out.println(singleton05);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
